package tests;

import static org.junit.Assert.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.naming.InitialContext;

import org.junit.Test;

import utils.DataMiner;

public class DataMinerTests {
	InitialContext ic;
	@Test
	public void ConstructorTest() {
		DataMiner dm = null;
		assertTrue(dm == null);
		
		dm = new DataMiner();
		assertFalse(dm == null);
	}
	
	@Test
	public void valColorMapResultTest(){
		DataMiner dm = new DataMiner();
		try {
			Map<String, Integer> m = null;
			assertTrue(m == null);
			
			dm.buildCartigesAndValue("http://10.130.2.64/");
			m = dm.getColorVals();
			
			assertFalse(m.isEmpty());
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Test
	public void addNewColorValTest(){
		DataMiner dm = new DataMiner();
		dm.addNewColorValTest("Test1", 1);
		assertTrue(!dm.getColorVals().isEmpty());
		dm.addNewColorValTest("Test1", 1);
		assertTrue(dm.getColorVals().size() == 1);
		dm.addNewColorValTest("Test2", 2);
		assertTrue(dm.getColorVals().size() == 2);
	}
	
	@Test 
	public void findCartigesColorTest() {
		DataMiner dm = new DataMiner();
		
		try {
			List<String> l = dm.findCartigesColor(dm.getUrlSourceTest("http://10.130.2.64/"));
			assertTrue(!l.isEmpty());
			assertTrue(l.size() == 4);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
		
	@Test
	public void findCartigesProcentTest() {
		DataMiner dm = new DataMiner();
		
		try {
			List<Integer> l = dm.findCartegisProcentr(dm.getUrlSourceTest("http://10.130.2.64/"));
			assertTrue(!l.isEmpty());
			assertTrue(l.size() == 4);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
